<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>综合查询</title>
    <link type="text/css" href="css/base.css" rel="stylesheet"/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/menu.js"></script>

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script src='<%=basePath%>dwr/util.js' type="text/javascript"></script>
    <script src='<%=basePath%>dwr/engine.js' type="text/javascript"></script>
    <script src='<%=basePath%>dwr/interface/campusService.js' type="text/javascript"></script>
    <script src='<%=basePath%>dwr/interface/collegeService.js' type="text/javascript"></script>
    <script src='<%=basePath%>dwr/interface/majorService.js' type="text/javascript"></script>
    <!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
    <script type="text/javascript">
        $(document).ready(function () {
            campusService.findAll(getCampus);
        });

        function getCampus(thelist) {
            var select_list = '<option value="" style="text-align: center">' + '---------请选择---------' + '</option>';
            for (var i = 0; i < thelist.length; i++) {
                select_list += '<option style="text-align: center" value="' + thelist[i].campusName + '">'
                        + thelist[i].campusName + "</option>";
            }
            $("#campusList1").html(select_list);
        }

        function findCollege(campus) {
            collegeService.findCollegeByCampus(campus, getCollege);
        }

        function findMajor(college) {
            majorService.findByCollege(college, getMajor);
        }

        function getCollege(thelist) {
            var select_list = '<option value="" style="text-align: center">' + '---------请选择---------' + '</option>';
            for (var i = 0; i < thelist.length; i++) {
                select_list += '<option style="text-align: center" value="' + thelist[i].id + '">'
                        + thelist[i].collegeName + "</option>";
            }
            $("#collegeList1").html(select_list);
        }

        function getMajor(thelist) {
            var select_list = '<option value="" style="text-align: center">' + '---------请选择---------' + '</option>';
            for (var i = 0; i < thelist.length; i++) {
                select_list += '<option style="text-align: center" value="' + thelist[i].majorId + '">'
                        + thelist[i].majorName + "</option>";
            }
            $("#majorList1").html(select_list);
        }
        function actionEvent(value) {
            var form = document.getElementById("myform");
            if (value == "下载数据") {
                form.action = "FileDownload.action";
                form.submit();
            }
            else {
                form.action = "Student!findStudentByCollegeAndMajor.action";
                form.submit();
            }
        }
    </script>
</head>

<body>
<%@ include file="/page/share/menu.jsp" %>

<div id="content" style="width: 1000px;margin-left: 17%;">
    <form method="post" action="Student!findStudentByCollegeAndMajor.action" id="myform">
        <table style="margin-left:20%:">
            <tr>
                <td align="right">
                    校&nbsp;&nbsp;区&nbsp;：
                </td>
                <td style=" width: 160px;">
                    <label>
                        <select name="campus" style="height: 23px;margin: 2px auto;  width: 150px;" id="campusList1"
                                onchange="findCollege(this.value)">
                        </select>
                    </label>
                </td>
            </tr>
            <tr>
                <td align="right">
                    学&nbsp;&nbsp;院&nbsp;：
                </td>
                <td style=" width: 160px;">
                    <label>
                        <select name="college" style="height: 23px;margin: 2px auto;  width: 150px;" id="collegeList1"
                                onchange="findMajor(this.value)">
                        </select>
                    </label>
                </td>
            </tr>
            <tr>
                <td align="right">
                    专&nbsp;&nbsp;业&nbsp;：
                </td>
                <td style=" width: 160px;">
                    <label>
                        <select name="major" style="height: 23px;margin: 2px auto;  width: 150px;" id="majorList1">
                        </select>
                    </label>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input onclick="actionEvent(this.value)" type="submit" value="在线查询"
                           onMouseOver="this.style.background='#2569c1'"
                           onmouseout="this.style.background='#114a93'"
                           style="width:150px;height:25px;cursor:pointer;border: none;background: #2569c1;color: white;font-size: 16px;"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input onclick="actionEvent(this.value)" type="submit" value="下载数据"
                           onMouseOver="this.style.background='#2569c1'"
                           onmouseout="this.style.background='#114a93'"
                           style="width:150px;height:25px;cursor:pointer;border: none;background: #2569c1;color: white;font-size: 16px;"/>
                </td>
            </tr>
        </table>
    </form>
    <form method="post" action="" align="center">
        <table align="center"
               style="margin: 40px auto 20px;background: #114a93;opacity:0.9;font-family: '微软雅黑',serif;color: linen;width:
    1000px;text-align: center">
            <thead align="center">
            <tr>
                <th>
                    学 号
                </th>
                <th>
                    离校时间
                </th>
                <th>
                    宿舍角色
                </th>
                <th>
                    电 话
                </th>
                <th>
                    性 别
                </th>
                <th>
                    姓 名
                </th>
                <th>
                    宿 舍
                </th>
                <th>
                    专 业
                </th>
            </tr>
            </thead>
            <s:iterator value="students" var="s">
                <tr align="center">
                    <td>
                            <s:property value="#s.studentId"/>
                        &nbsp;
                    <td>
                        <s:property value="#s.leaveDate"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.monitor"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.phone"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.sex"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.studentName"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.dormitory.dormitoryId"/>
                        &nbsp;
                    </td>
                    <td>
                        <s:property value="#s.major.majorName"/>
                        &nbsp;
                    </td>
                </tr>
            </s:iterator>
        </table>
    </form>
</div>


<div id="footer">
    <p style="text-align: center;color: #757575;padding: 20px 0px 0px 0px; font:12px;">Copyright © 2010-2013 蓝天白云团队
        版权所有</p>
</div>
</body>
</html>